import time
from multiprocessing import Process, Queue, Pool, Manager
# from queue import Queue

# def producer(queue):
#     queue.put("a")
#     time.sleep(2)
#
# def consumer(queue):
#     time.sleep(2)
#     data = queue.get()
#     print(data)

# 共享全局变量通信
# 共享全局变量不能适用于多进程编程，可以适用于多线程
def producer(a):
    a += 1
    time.sleep(2)

def consumer(a):
    time.sleep(2)
    print(a)

if __name__ == '__main__':
    # queue = Queue(10)
    a = 1
    my_producer = Process(target=producer, args=(a,))
    my_consumer = Process(target=consumer, args=(a,))
    my_producer.start()
    my_consumer.start()
    my_producer.join()
    my_consumer.join()


